﻿//autocomplete 品名
jQuery(function ($) {
    var tmp_data_品名;

    $("#MainContent_txt品名CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH002.ashx",
                dataType: "json",
                data: { "KEY1": $("#MainContent_txt品名CD").val() },
                success: function (data) {
                    tmp_data_品名 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEY1 + "\t" + item.CODE1_HANZI,
                            value: item.KEY1,
                            CODE1_HANZI: item.CODE1_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt品名").html(ui.item.CODE1_HANZI);
            $("#MainContent_hid品名").val($("#MainContent_txt品名").html());
        }
    });

    $("#MainContent_txt品名CD").focusout(function () {
        if (tmp_data_品名 != null) $("#MainContent_txt品名").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_品名, function (i, v) {
            if (v.KEY1 == $("#MainContent_txt品名CD").val()) {
                $("#MainContent_txt品名").html(v.CODE1_HANZI);
                $("#MainContent_hid品名").val($("#MainContent_txt品名").html());
                return;
            }
        });

    });
});

//autocomplete 指示状态
jQuery(function ($) {
    var tmp_data_指示状态;

    $("#MainContent_txt指示状态CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH019.ashx",
                dataType: "json",
                data: { "KEY1": $("#MainContent_txt指示状态CD").val() },
                success: function (data) {
                    tmp_data_指示状态 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEY1 + "\t" + item.CODE1_HANZI,
                            value: item.KEY1,
                            CODE1_HANZI: item.CODE1_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt指示状态").html(ui.item.CODE1_HANZI);
            $("#MainContent_hid指示状态").val($("#MainContent_txt指示状态").html());
        }
    });

    $("#MainContent_txt指示状态CD").focusout(function () {
        if (tmp_data_指示状态 != null) $("#MainContent_txt指示状态").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_指示状态, function (i, v) {
            if (v.KEY1 == $("#MainContent_txt指示状态CD").val()) {
                $("#MainContent_txt指示状态").html(v.CODE1_HANZI);
                $("#MainContent_hid指示状态").val($("#MainContent_txt指示状态").html());
                return;
            }
        });

    });
});

//autocomplete 所用车型
jQuery(function ($) {
    var tmp_data_所用车型;

    $("#MainContent_txt所用车型CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH015.ashx",
                dataType: "json",
                data: { "KEY1": $("#MainContent_txt所用车型CD").val() },
                success: function (data) {
                    tmp_data_所用车型 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEY1 + "\t" + item.CODE1_HANZI,
                            value: item.KEY1,
                            CODE1_HANZI: item.CODE1_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt所用车型").html(ui.item.CODE1_HANZI);
            $("#MainContent_hid所用车型").val($("#MainContent_txt所用车型").html());
        }
    });

    $("#MainContent_txt所用车型CD").focusout(function () {
        if (tmp_data_所用车型 != null) $("#MainContent_txt所用车型").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_所用车型, function (i, v) {
            if (v.KEY1 == $("#MainContent_txt所用车型CD").val()) {
                $("#MainContent_txt所用车型").html(v.CODE1_HANZI);
                $("#MainContent_hid所用车型").val($("#MainContent_txt所用车型").html());
                return;
            }
        });

    });
});


//autocomplete 车主
jQuery(function ($) {
    var tmp_data_车主;

    $("#MainContent_txt车主CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH001.ashx",
                dataType: "json",
                data: { "KEHU_CD": $("#MainContent_txt车主CD").val(), "GONGSI_XINGZHI": "" }, //TODO
                success: function (data) {
                    tmp_data_车主 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEHU_CD + "\t" + item.KEHU_HANZI,
                            value: item.KEHU_CD,
                            KEHU_HANZI: item.KEHU_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt车主").html(ui.item.KEHU_HANZI);
            $("#MainContent_hid车主").val($("#MainContent_txt车主").html());
        }
    });

    $("#MainContent_txt车主CD").focusout(function () {
        if (tmp_data_车主!=null) $("#MainContent_txt车主").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_车主, function (i, v) {
            if (v.KEHU_CD == $("#MainContent_txt车主CD").val()) {
                $("#MainContent_txt车主").html(v.KEHU_HANZI);
                $("#MainContent_hid车主").val($("#MainContent_txt车主").html());
                return;
            }
        });

    });
});


//autocomplete 装货地
jQuery(function ($) {
    var tmp_data_装货地;

    $("#MainContent_txt装货地CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH001.ashx",
                dataType: "json",
                data: { "KEHU_CD": $("#MainContent_txt装货地CD").val(), "GONGSI_XINGZHI": "" }, //TODO
                success: function (data) {
                    tmp_data_装货地 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEHU_CD + "\t" + item.KEHU_HANZI,
                            value: item.KEHU_CD,
                            KEHU_HANZI: item.KEHU_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt装货地").html(ui.item.KEHU_HANZI);
            $("#MainContent_hid装货地").val($("#MainContent_txt装货地").html());
        }
    });

    $("#MainContent_txt装货地CD").focusout(function () {
        if (tmp_data_装货地!=null) $("#MainContent_txt装货地").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_装货地, function (i, v) {
            if (v.KEHU_CD == $("#MainContent_txt装货地CD").val()) {
                $("#MainContent_txt装货地").html(v.KEHU_HANZI);
                $("#MainContent_hid装货地").val($("#MainContent_txt装货地").html());
                return;
            }
        });

    });
});


//autocomplete 卸货地
jQuery(function ($) {
    var tmp_data_卸货地;

    $("#MainContent_txt卸货地CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH001.ashx",
                dataType: "json",
                data: { "KEHU_CD": $("#MainContent_txt卸货地CD").val(), "GONGSI_XINGZHI": "" }, //TODO
                success: function (data) {
                    tmp_data_卸货地 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEHU_CD + "\t" + item.KEHU_HANZI,
                            value: item.KEHU_CD,
                            KEHU_HANZI: item.KEHU_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt卸货地").html(ui.item.KEHU_HANZI);
            $("#MainContent_hid卸货地").val($("#MainContent_txt卸货地").html());
        }
    });

    $("#MainContent_txt卸货地CD").focusout(function () {
        if (tmp_data_卸货地!=null) $("#MainContent_txt卸货地").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_卸货地, function (i, v) {
            if (v.KEHU_CD == $("#MainContent_txt卸货地CD").val()) {
                $("#MainContent_txt卸货地").html(v.KEHU_HANZI);
                $("#MainContent_hid卸货地").val($("#MainContent_txt卸货地").html());
                return;
            }
        });

    });
});
